package kr.ac.jejunu.controller;

import kr.ac.jejunu.model.User;
import kr.ac.jejunu.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(value="/join")
public class UserController {
	
	@Autowired UserService userService;
	
	@RequestMapping(method=RequestMethod.GET)
	public String showForm(){
		return "join";
	}
	
	@RequestMapping(method=RequestMethod.POST)
	public String save(@ModelAttribute("user") User user){
		userService.saveUser(user);
		return "redirect:/main";
	}
}